package com.cjh.wechat.core.controller;

import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.cjh.wechat.commom.pojo.Team;
import com.cjh.wechat.core.service.TeamService;

@Controller
@RequestMapping("/team")
public class TeamController
{
    @Resource
    private TeamService teamService;
    
    @ResponseBody
    @RequestMapping(value = "/delTeam", method = RequestMethod.POST)
    public String delTeam(String uid, Integer no)
    {
        try
        {
            teamService.delTeam(uid, no);
            return "success";
        }
        catch (Exception e)
        {
            return "fail";
        }
    }
    
    @ResponseBody
    @RequestMapping(value = "/addTeam", method = RequestMethod.POST)
    public String addTeam(String id, String name)
    {
        try
        {
            teamService.addTeam(id, name);
            return "success";
        }
        catch (Exception e)
        {
            return "fail";
        }
    }
    
    @ResponseBody
    @RequestMapping(value = "/showTeamExcludeFriendId", method = RequestMethod.POST)
    public List<Team> showTeamExcludeFriendId(String id, String friendId)
    {
        List<Team> teams = teamService.showTeamExcludeFriendId(id, friendId);
        return teams;
    }
    
    @ResponseBody
    @RequestMapping(value = "/showTeamById", method = RequestMethod.POST)
    public List<Team> showTeamById(String id)
    {
        return teamService.showTeamById(id);
    }
}
